
package com.work.util;

import org.apache.commons.lang.exception.ExceptionUtils;

public class ControllerException extends Exception {

	private static final long serialVersionUID = 6274228413410888381L;

	private String message;

	private Exception exception;

	public ControllerException()
	{
		super();
	}

	public ControllerException(Exception exception)
	{
		super();
		this.exception = exception;
	}

	public ControllerException(String message)
	{
		super();
		this.message = message;
	}

	public ControllerException(String message, Exception exception)
	{
		super();
		this.message = message;
		this.exception = exception;
	}

	public String getMessage()
	{
		return message;
	}

	public void setMessage(String message)
	{
		this.message = message;
	}

	public Exception getException()
	{
		return exception;
	}

	public void setException(Exception exception)
	{
		this.exception = exception;
	}

	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();

		if (message != null) {
			sb.append(message);
		}

		if (exception != null) {
			sb.append(": ");
			sb.append(ExceptionUtils.getStackTrace(exception));
		}

		return sb.toString();
	}

}
